package com.xinnet.mms.customercare.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.xinnet.core.dao.impl.BaseDaoImpl;
import com.xinnet.mms.customercare.dao.CustomerCareDao;
import com.xinnet.mms.entity.CustomerCare;



@Repository("customerCareDao")
public class CustomerCareDaoImpl extends BaseDaoImpl<CustomerCare,Long> implements  CustomerCareDao{
	
	public CustomerCare getCustomerCareByCustomIdAndProductId(String customId ,String productId){
		CustomerCare params =  new CustomerCare(); 
		params.setCusId(customId);
		params.setProductId(productId);
		CustomerCare customerCare = super.getSqlSession().selectOne("customerCare.getCustomerCareByCustomIdAndProductId",params);
		return customerCare;
	}
	
	public boolean isUseOtherProduct(String customId ,String productId){
		CustomerCare params =  new CustomerCare(); 
		params.setCusId(customId);
		params.setProductId(productId);
		CustomerCare customerCare = super.getSqlSession().selectOne("customerCare.isUseOtherProduct",params);
		if(customerCare!=null){
			return true;
		}else{
			return false;
		}
	}
	
	public List<String> getCustomerCareCustomerIdList(){
		List<String> customerIdList = super.getSqlSession().selectList("customerCare.getCustomerCareCustomerIdList");
		if(customerIdList!=null && customerIdList.size()==0){
			return null;
		}
		return customerIdList;
	}
	
	public void addCustomerCare(CustomerCare customerCare){
		super.getSqlSession().insert("customerCare.addCustomerCare",customerCare);
	}

	/**添加订单*/
	@Override
	public void addOrders(CustomerCare customerCare) {
		this.getSqlSession().insert("customerCare.addOrders",customerCare);
	}

	/**用会员ID取得该会员的订单信息 */
	@Override
	public List<CustomerCare> getOrdersByCusId(String cus_id) {
		List<CustomerCare> list=this.getSqlSession().selectList("customerCare.getOrdersByCusId", cus_id);
		if(list==null || list.isEmpty()) {
			return null;
		}
		return list;
	}

}
